﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using Ninject;
using Tisonet.Dobrak.Domain.Services.Downloaders;
using Tisonet.Dobrak.Domain.Services.Movies;
using Tisonet.Dobrak.Domain.Services.Projections;
using Tisonet.Dobrak.Services;
using Tisonet.Dobrak.Services.Movies;
using Tisonet.Dobrak.Services.Projections;

namespace Tisonet.Dobrak.Web.App_Start
{
    public class IocConfig
    {
        public static void RegisterIoc(HttpConfiguration config)
        {
            var kernel = new StandardKernel(); // Ninject IoC
            //kernel.Load(Assembly.GetExecutingAssembly()); //only required for asp.net mvc (not for webapi)
            // These registrations are "per instance request".
            // See http://blog.bobcravens.com/2010/03/ninject-life-cycle-management-or-scoping/

            kernel.Bind<IProjectionsService>().To<ProjectionsService>();
            kernel.Bind<IProjectionsProvider>().To<DobrakProjectionsProvider>();
            kernel.Bind<IDownloader>().To<HttpDownloader>();

            kernel.Bind<IMoviesService>().To<MoviesService>();
            kernel.Bind<IMoviesProvider>().To<DobrakMoviesProvider>();

            // Tell WebApi how to use our Ninject IoC
            config.DependencyResolver = new NinjectDependencyResolver(kernel);
        }
    }
}